'''
Raid TD - Tower Class
Programmer: Oscar
Date: 4/18/2014
'''

import pygame, random, sys, math
from pygame.locals import *
from Bullet import *


diamondImage = pygame.image.load("./gfx/diamond.png")
stoneImage = pygame.image.load("./gfx/stone.jpg")
cobbleImage = pygame.image.load("./gfx/cobble.png")

rangeColor = (147, 154, 189)
towerlevel1Color = (0, 255, 255)
towerlevel2Color = (102, 102, 153)
towerlevel3Color = (255, 102, 0)

#Tower class
class Tower:
    def __init__(self, rect, screen):
        self.screen = screen
        self.rect = rect
        self.radius = 100
        self.center = (self.rect.x+16, self.rect.y+16)
        self.attack = 5
        self.lvl = 1
        self.ammo = Bullet(screen, self.center)

    def upgrade(self):
        if self.lvl < 3:
            self.lvl += 1
            self.attack += 25
            self.radius += 20
        else:
            print("Tower Fully Upgraded")
                    
    def drawTower(self):
        if self.lvl == 1:
            #pygame.draw.rect(self.screen,towerlevel1Color, self.rect,5)
            self.screen.blit(cobbleImage,self.rect)
        elif self.lvl == 2:
            #pygame.draw.rect(self.screen,towerlevel2Color, self.rect,5)
            self.screen.blit(stoneImage,self.rect)
        else:
            #pygame.draw.rect(self.screen,towerlevel3Color, self.rect,5)
            self.screen.blit(diamondImage,self.rect)

    def drawRange(self):
        pygame.draw.circle(self.screen, rangeColor, self.center, self.radius, 1)

    def detectEnemy(self,enemyPos):
        self.ammo.launchToTarget(enemyPos)






